﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MyHotel.MyHotel_MHPhong_BUS_Webservice;

namespace MyHotel
{
    public partial class uscRoom : UserControl
    {
        public delegate void StateChange(StateRoom state);
        public event StateChange ChangeState;
        private StateRoom _state = null;
        private Phong _phong;

        public Phong Phong
        {
            get { return _phong; }
            set
            {
                _phong = value;
                if (_phong != null)
                {
                    buttonX1.Text = "Phòng : " + _phong.TenPhong; 
                }
            }
        }
   
        public StateRoom State
        {
            get { return _state; }
            set
            {
                if (_state != null && _state != value)
                {
                    if (ChangeState != null)
                    {
                        ChangeState(value);
                    }
                }
                _state = value;
                if (State != null)
                {
                    buttonX1.Image = State.getImage(); 
                }
            }
        }  

        public uscRoom(Phong p, StateRoom stt)
        {
            InitializeComponent();
            State = stt;
            Phong = p;
        } 

        private void buttonX1_Click(object sender, EventArgs e)
        {
            if (State != null)
            {
                State.LeftClick(Phong, this);
            }
        } 
    }
}
